﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DataBaseManager;
using System.Data;

namespace BLGPS
{
    public class CommonBase
    {
        public decimal Id { get; set; }
        public string Name { get; set; }
        public CommonBase()
        {

        }
        public override string ToString()
        {
            return Name;
        }

         public CommonBase(decimal id, string name)
        {
            Id = id;
            Name = name;
        }
        
    }
    public class CommonBaseManager<T> : List<T> where T : CommonBase, new()
    {
        public T GetById(decimal pId)
        {
            foreach (T m in this)
            {
                if (m.Id == pId) return m;
            }
            return null;
        }
        
       /* public static U LoadAll<U>(TableName pTabla) where U : CommonBaseManager<T>, new()
        {
            U mLista = new U();

            DataTable vTabla = BaseDatos.DB.ExecuteSelectCommand(pTabla);
            foreach (DataRow r in vTabla.Rows)
            {
                T p = new T();
                p.Id = decimal.Parse(r["id"].ToString());
                p.Name = r["nombre"].ToString();
                mLista.Add(p);
            }
            return mLista;
        }*/
    }  
}
